import logging

logger = logging.getLogger('sourceDns.webdns.views')


'''
####################################################################################
use:装饰器
date:2018-5-14 13:00
author:Heanny
'''


def _isLogin(func):
	@wraps(func)
	def returned_wrapper(req, *args, **kwargs):
		try:
			username = req.session.get('user')
			if username is None:
				return redirect('/login.html?url={}'.format(req.path[1:]))
			else:
				return func(req, *args, **kwargs)
		except Exception as e:
			print('\n_isLogin error:{}\n'.format(e))
			logger.error(e)
			# return redirect('/login{}'.format(req.path))
			raise Http404()

	return returned_wrapper


'''
装饰器结束
####################################################################################
'''
